package models;

import java.util.*;

import javax.persistence.*;

//import models.RegisteredUser;

import play.data.validation.Required;
import play.db.jpa.*;

@Entity
public class CommunityList extends Model {

	/**Ayatullah Marawan*/
	@Required
	public String name;
	/**Ayatullah Marawan*/
	public int score;
	/**Ayatullah Marawan*/
	public Date postingDate = new Date();
	
	public ArrayList joinList;
	@ManyToMany
	@JoinTable(name = "communityListMembers")
	public List<RegisteredUser> membersList;
	/**Ayatullah Marawan*/
	@ManyToOne
	@JoinColumn(name = "creatorIdMapping")
	public RegisteredUser creator;
	/**ebaa*/
	@ManyToOne
	@JoinColumn(name = "ownerOfComm")
	public RegisteredUser owner;

	// Start Mayar
	@ManyToMany
	@JoinTable(name = "recommendedTut")
	public List<Tutorial> recommendList;

	@ManyToMany
	@JoinTable(name = "recommendedTopic")
	public List<Topic> recommendListTopic;

	// Start Mayar
	@ManyToMany
	@JoinTable(name = "recommendedExercise")
	public List<Exercise> recommendListExercise;

	// End Mayar

	// public List<RegisteredUser> getMembersList() {
	// return membersList;
	// }
	//
	//
	// public void setMembersList(List<RegisteredUser> membersList) {
	// this.membersList = membersList;
	// }
	//

	public CommunityList(String name, RegisteredUser creator) 
	{

		this.creator = creator;
		this.name = name;
		this.score = 0;
		// this.membersList = new ArrayList<RegisteredUser>();
		this.membersList = new ArrayList();
		this.recommendListTopic = new ArrayList<Topic>();
		this.recommendList = new ArrayList<Tutorial>();
		this.recommendListExercise = new ArrayList<Exercise>();
		this.save();

	}

	 /**
		 * getter for Creator attribute
		 * 
		 * @author ayatullah Marwan
		 * @return RegisteredUser
		 */
	public RegisteredUser getCreator() {
		return creator;
	}

	/**
	 * setter for Creator attribute
	 * 
	 * @author ayatuulah marwan
	 * @param RegisteredUser creator
	 *            
	 */
	public void setCreator(RegisteredUser creator) {
		this.creator = creator;
	}


	 /**
		 * getter for name attribute
		 * 
		 * @author ayatullah Marwan
		 * @return String name
		 */
	public String getName() {
		return name;
	}

	// Begin ----> Ebaa
	/**
	 * getter for membersList attribute
	 * 
	 * @author Ebaa
	 * @return List<RegisteredUser>
	 */
	public List<RegisteredUser> getMembersList() {
		return membersList;
	}

	/**
	 * setter for membersList attribute
	 * 
	 * @author Ebaa
	 * @param membersList
	 *            list of members in a community list
	 */
	public void setMembersList(List<RegisteredUser> membersList) {
		this.membersList = membersList;
	}

	/**
	 * getter for owner attribute
	 * 
	 * @author Ebaa
	 * @return RegisteredUser
	 */
	public RegisteredUser getOwner() {
		return owner;
	}

	/**
	 * setter for membersList attribute
	 * 
	 * @author Ebaa
	 * @param owner
	 *            owner of community list
	 */
	public void setOwner(RegisteredUser owner) {
		this.owner = owner;
	}
	// End ----> Ebaa
}
